@extends('layouts.header')
@section('title','扫描二维码或RFID码')
@section('style')
    .trChecked {
    background-color: #9bf5f5;
    }
@endsection
@section('content')
    <article class="page-container">
        <div class="btn btn-primary radius size-M f-l" id="sub">确 定</div>
        <table class="table table-border table-bordered table-hover table-bg" id="datatable">
            <thead>
            <tr>
                <th>选择</th>
                <th>批次号</th>
                <th>送检单位</th>
            </tr>
            </thead>
            <tbody>
            @foreach($data as $item)
                <tr>
                    <td><input type="radio"  name="batchNum" data-id="{{$item->id}}" value="{{$item->batchNum}}"></td>
                    <td style="width: 30%;">{{$item->batchNum}}</td>
                    <td style="width: 70%;">{{$item->client_name}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </article>
    <script>
        $(function () {
            $('#datatable').DataTable({
                paging: false,
                ordering: false
            })
            $('#datatable_filter').css('margin-bottom', '10px')
        });
        $('tbody tr').on('click', function () {
            $(this).find('input[name=batchNum]').prop('checked','checked');
        });
        $('#sub').on('click',function () {
            let ele = $('input[name=batchNum]:checked');
            let batchNum = ele.val();
            // 子窗体传值到父窗体 uids是父页面的一个dom
            $('#batchNum',window.parent.document).text(batchNum);
            $('input[name=contract_id]',window.parent.document).val(ele.data('id'));
            layer_close();
        })
    </script>
@endsection